/**
 * 后端API响应示例
 *
 * 这个文件展示了后端API应该返回的数据格式，用于指导后端开发
 */

// GET /dashboard/user/verifyStats 用户实名统计接口响应示例
export const userVerifyStatsApiResponse = {
  success: true,
  message: '获取用户实名统计数据成功',
  code: 200,
  timestamp: '2025-01-14T10:30:00Z',
  result: {
    // 已实名用户数
    verify_count: 1268,
    // 小程序用户总数
    total_count: 2340,
    // 实名率（百分比）
    verify_rate: 54.2,
    // 增长率（百分比）
    growth_rate: 8.5,
    // 统计周期
    period: '月',
    // 额外信息
    extra: {
      // 本月新增实名用户数
      newVerifyUsersThisMonth: 89,
      // 上月同期对比
      lastMonthComparison: {
        verify_count: 1156,
        total_count: 2198,
        verify_rate: 52.6,
        growth_rate: 7.2,
      },
    },
  },
};

// GET /dashboard/order/stats 接口响应示例
export const orderStatsApiResponse = {
  success: true,
  message: '获取订单统计数据成功',
  code: 200,
  timestamp: '2025-01-14T10:30:00Z',
  result: {
    // 当前周期（月）订单金额
    currentAmount: 156780.50,
    // 总订单金额
    totalAmount: 2340000.00,
    // 订单数量
    orderCount: 1268,
    // 增长率（百分比）
    growthRate: 12.5,
    // 统计周期
    period: '月',
    // 额外信息
    extra: {
      // 平均订单金额
      avgOrderAmount: 123.56,
      // 本月新增订单数
      newOrdersThisMonth: 89,
      // 上月同期对比
      lastMonthComparison: {
        amount: 140230.25,
        count: 1145,
        growthRate: 11.8
      }
    }
  }
};

// GET /dashboard/order/monthlyAmount 接口响应示例
export const monthlyOrderAmountApiResponse = {
  success: true,
  message: '获取月度订单金额成功',
  code: 200,
  result: {
    year: 2025,
    month: 1,
    totalAmount: 156780.50,
    orderCount: 1268,
    // 按日期分组的详细数据
    dailyData: [
      { date: '2025-01-01', amount: 5420.30, count: 42 },
      { date: '2025-01-02', amount: 6780.50, count: 51 },
      // ... 更多日期数据
    ]
  }
};

/**
 * 后端SQL查询示例（仅供参考）
 * 
 * -- 获取月度订单统计
 * SELECT 
 *   SUM(order_amount) as currentAmount,
 *   COUNT(*) as orderCount,
 *   AVG(order_amount) as avgOrderAmount
 * FROM nurse_user_orders 
 * WHERE DATE_FORMAT(create_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m')
 *   AND order_status IN ('completed', 'paid');
 * 
 * -- 获取总订单金额
 * SELECT SUM(order_amount) as totalAmount 
 * FROM nurse_user_orders 
 * WHERE order_status IN ('completed', 'paid');
 * 
 * -- 计算增长率
 * SELECT 
 *   (current_month.amount - last_month.amount) / last_month.amount * 100 as growthRate
 * FROM 
 *   (SELECT SUM(order_amount) as amount FROM nurse_user_orders 
 *    WHERE DATE_FORMAT(create_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m')) current_month,
 *   (SELECT SUM(order_amount) as amount FROM nurse_user_orders 
 *    WHERE DATE_FORMAT(create_time, '%Y-%m') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y-%m')) last_month;
 */

/**
 * 后端Controller示例（Java SpringBoot）
 * 
 * @RestController
 * @RequestMapping("/dashboard/order")
 * public class OrderStatsController {
 * 
 *   @Autowired
 *   private OrderStatsService orderStatsService;
 * 
 *   @GetMapping("/stats")
 *   public Result<OrderStatsVO> getOrderStats(
 *     @RequestParam(defaultValue = "month") String period,
 *     @RequestParam(required = false) Integer year,
 *     @RequestParam(required = false) Integer month
 *   ) {
 *     try {
 *       OrderStatsVO stats = orderStatsService.getOrderStats(period, year, month);
 *       return Result.ok(stats);
 *     } catch (Exception e) {
 *       log.error("获取订单统计数据失败", e);
 *       return Result.error("获取订单统计数据失败");
 *     }
 *   }
 * }
 * 
 * // VO类定义
 * public class OrderStatsVO {
 *   private BigDecimal currentAmount;
 *   private BigDecimal totalAmount;
 *   private Long orderCount;
 *   private BigDecimal growthRate;
 *   private String period;
 *   // getters and setters...
 * }
 */